Page({
  onLoad() {
    this.chooseImg();
  },
  // 上传图片第一步，选择图片
  chooseImg() {
    let that = this;
    wx.chooseImage({
      count: 1,
      sourceType: ['album', 'camera'],
      success(res) {
        that.upLoadImg(res.tempFilePaths[0])
      }
    })
  },
  // 上传图片第二步 直接上传图片到云存储
  upLoadImg(temFile) {
    console.log(temFile, '零时路径')
    wx.cloud.uploadFile({
      cloudPath: "魏彭雨.jpg",
      filePath: temFile,
      success: res => {
        console.log(res, '上传成功')
      },
      fail: err => {
        console.log(err, '上传失败')
      }
    })
  }
})